package cn.hotel.utlis;

import java.util.ArrayList;
import java.util.List;

public class PageBean<T> {
    // 当前页码
    private int currPageNo = 1;
    // 页面大小，即每页显示记录数
    private int pageSize = 10;
    // 记录总数
    private int totalCount;
    // 总页数
    private int totalPageCount;
    //每页显示的数据
    private List<T> productList = new ArrayList<T>();

    public int getCurrPageNo() {
        return currPageNo;
    }

    public void setCurrPageNo(int currPageNo) {
        if(currPageNo <1){
            currPageNo = 1;
        }
        if (totalPageCount > 0 && currPageNo > this.totalPageCount) {
            currPageNo = this.totalPageCount;
        }
        this.currPageNo = currPageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        //计算总页数
        int totalPage = totalCount % this.pageSize == 0 ?
                totalCount/this.pageSize : totalCount/this.pageSize + 1;
        this.totalPageCount = totalPage;
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    public List<T> getProductList() {
        return productList;
    }

    public void setProductList(List<T> productList) {
        this.productList = productList;
    }

}
